<template>
	<view class="container">
		<view class="margin-left-sm margin-right-sm padding-sm bg-white radius10   flex justify-start margin-top"
			v-for='(item,index) in list' :key='index'>
			<image :src="item.headImg" mode="" class="round" style="width: 60rpx;height: 60rpx;min-width: 60rpx;">
			</image>
			<view class="margin-left-xs">
				<view class="text-df text-999 padding-top-xs">
					{{item.nickName}}
				</view>
				<view v-if="type==1" class="">
					<view class="text-15 text-333 margin-top-sm">
						{{item.content ||'暂无数据'}}
					</view>
					<view class="flex flex-wrap justify-start margin-top" v-if='item.appendix'>
					
						<image :src="value" class="margin-top-xs" v-for="(value,i) in item.appendix.split(',')"
							:class="{'margin-left-xs':(index+3)%3!=0}" mode="" style="width: 150rpx;height: 150rpx;">
						</image>
					
					</view>
				</view>
				<view v-else class="">
					<view class="text-15 text-333 show-text margin-top-sm" style="width:600rpx;">
						{{item.content ||'暂无数据'}}
					</view>
					<view class="flex flex-wrap justify-start margin-top" v-if='item.appendix'>

						<image :src="value" class="margin-top-xs" v-for="(value,i) in item.appendix.split(',')"
							:class="{'margin-left-xs':(index+3)%3!=0}" mode="" style="width: 150rpx;height: 150rpx;">
						</image>

					</view>
				</view>

				<view class="margin-top-sm text-sm text-999">
					{{item.createTime}}
				</view>
			</view>
		</view>
		<uni-load-more :status="loading" />
	</view>
</template>

<script>
	import BetterPull from '@/common/libs/BetterPull'
	export default {
		mixins: [
			BetterPull({
				async getPage(page, done) {
					this.loading = 'loading';
					let param;
					let api = ' '
					if (this.type) {
						api = 'toCommentList'
						param = {
							pageNum: page,
							pageSize: 10,
							// userId: uni.getStorageSync('userId'),
							// receiverId: uni.getStorageSync('userId'),
							orderProductId: this.id
						}
					} else {
						api = 'listOrderServiceComment'
						param = {
							pageNum: page,
							pageSize: 10,
							orderServiceId: this.id,
							receiverId: this.receiverId,
							userId: this.userId

						}
					}

					const [err, res] = await this.$get(this.$api[api], param)
					if (res) {
						var data = res.data.list
						done(data);
						if (data.length < 10) {
							this.loading = 'noMore';
						} else {
							this.loading = 'more';
						}

					}
					if (err) {
						done([]);
						this.loading = 'noMore';
					}
				}
			})
		],
		data() {
			return {
				id: '',
				loading: 'more',
				url: this.$api.commentList,
				type: '',
				userId: '',
				receiverId: ''
			}
		},
		onLoad(options) {
			console.log(options)
			if (options.id) {
				this.id = options.id
			}
			if (options.type) {
				console.log(options.type)
				this.type = options.type
			} else {
				this.receiverId = options.receiverId
				this.userId = options.userId
			}

		},
		methods: {

		}
	}
</script>

<style scoped>
	.show-text {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
</style>
